#!/bin/sh

apt update && apt install git-lfs -y

# 如果没有文件夹，先创建一个。
mkdir -p models
cd models

# 下载 chatlgm3
if [ ! -d "Qwen-7B-Chat-Int4" ]; then
    echo "start downloading Qwen-7B-Chat"
    git clone https://www.modelscope.cn/qwen/Qwen-7B-Chat-Int4.git
    sleep 1
    # https://github.com/QwenLM/Qwen/issues/385
    # 解决 qwen 启动问题。 
    sed -i 's/"gptq"/"gptq","disable_exllama": true/g' Qwen-7B-Chat-Int4/config.json
    cat Qwen-7B-Chat-Int4/config.json | grep "gptq"
fi

# 下载 bge-large-zh
if [ ! -d "bge-large-zh-v1.5" ]; then
    echo "start downloading bge-large-zh-v1.5"
    git clone https://www.modelscope.cn/AI-ModelScope/bge-large-zh-v1.5.git
fi


cd ..
echo "docker-compose build and run"

docker-compose -f docker-compose-qwen7b.yml up -d
